Handle the case where there is no child text node. (GtkBuilderConverter):
authorJohan Dahlin <johan@gnome.org>
Fri, 25 Jan 2008 18:23:10 +0000 (18:23 +0000)
committerJohan Dahlin <johan@src.gnome.org>
Fri, 25 Jan 2008 18:23:10 +0000 (18:23 +0000)
2008-01-25  Johan Dahlin  <johan@gnome.org>

* gtk/gtk-builder-convert
(GtkBuilderConverter._convert_adjustment): Handle the case where
there is no child text node.
(GtkBuilderConverter): Allow xml comments in most places.

svn path=/trunk/; revision=19405

ChangeLog
gtk/gtk-builder-convert

index 762ccb54759524cb6bbfc78ef0d1a7b9f311b200..8111b3edbfe84c8b10617c5f9ed0d21e313807a4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-01-25  Johan Dahlin  <johan@gnome.org>
+
+       * gtk/gtk-builder-convert
+       (GtkBuilderConverter._convert_adjustment): Handle the case where
+       there is no child text node.
+       (GtkBuilderConverter): Allow xml comments in most places.
+
 2008-01-25  Johan Dahlin  <johan@gnome.org>
 
        * gtk/gtk-builder-convert
index 53fcb90c532cd21d67bf64b290989abffc60695b..689c96593ed3d5e1eb54c28b5816f265d22b670c 100755 (executable)
@@ -58,7 +58,7 @@ def get_child_nodes(node):
     assert node.tagName == 'object'
     nodes = []
     for child in node.childNodes:
-        if child.nodeType == Node.TEXT_NODE:
+        if child.nodeType != Node.ELEMENT_NODE:
             continue
         if child.tagName != 'child':
             continue
@@ -69,7 +69,7 @@ def get_properties(node):
     assert node.tagName == 'object'
     properties = {}
     for child in node.childNodes:
-        if child.nodeType == Node.TEXT_NODE:
+        if child.nodeType != Node.ELEMENT_NODE:
             continue
         if child.tagName != 'property':
             continue
@@ -86,7 +86,7 @@ def get_property_node(node, property_name):
     assert node.tagName == 'object'
     properties = {}
     for child in node.childNodes:
-        if child.nodeType == Node.TEXT_NODE:
+        if child.nodeType != Node.ELEMENT_NODE:
             continue
         if child.tagName != 'property':
             continue
@@ -97,7 +97,7 @@ def get_signal_nodes(node):
     assert node.tagName == 'object'
     signals = []
     for child in node.childNodes:
-        if child.nodeType == Node.TEXT_NODE:
+        if child.nodeType != Node.ELEMENT_NODE:
             continue
         if child.tagName == 'signal':
             signals.append(child)
@@ -107,8 +107,9 @@ def get_property_nodes(node):
     assert node.tagName == 'object'
     properties = []
     for child in node.childNodes:
-        if child.nodeType == Node.TEXT_NODE:
+        if child.nodeType != Node.ELEMENT_NODE:
             continue
+        # FIXME: handle comments
         if child.tagName == 'property':
             properties.append(child)
     return properties
@@ -117,7 +118,7 @@ def get_accelerator_nodes(node):
     assert node.tagName == 'object'
     accelerators = []
     for child in node.childNodes:
-        if child.nodeType == Node.TEXT_NODE:
+        if child.nodeType != Node.ELEMENT_NODE:
             continue
         if child.tagName == 'accelerator':
             accelerators.append(child)
@@ -127,7 +128,7 @@ def get_object_node(child_node):
     assert child_node.tagName == 'child', child_node
     nodes = []
     for node in child_node.childNodes:
-        if node.nodeType == Node.TEXT_NODE:
+        if node.nodeType != Node.ELEMENT_NODE:
             continue
         if node.tagName == 'object':
             nodes.append(node)
@@ -500,7 +501,7 @@ class GtkBuilderConverter(object):
 
         # 2) Get dialogs action-widgets tag, create if not found
         for child in dialog.childNodes:
-            if child.nodeType == Node.TEXT_NODE:
+            if child.nodeType != Node.ELEMENT_NODE:
                 continue
             if child.tagName == 'action-widgets':
                 actions = child
@@ -516,16 +517,22 @@ class GtkBuilderConverter(object):
         actions.appendChild(action)
 
     def _convert_adjustment(self, prop):
-        data = prop.childNodes[0].data
-        value, lower, upper, step, page, page_size = data.split(' ')
+        properties = {}
+        if prop.childNodes:
+            data = prop.childNodes[0].data
+            value, lower, upper, step, page, page_size = data.split(' ')
+            properties.update(value=value,
+                              lower=lower,
+                              upper=upper,
+                              step_increment=step,
+                              page_increment=page,
+                              page_size=page_size)
+        else:
+            prop.appendChild(self._dom.createTextNode(""))
+
         adj = self._create_root_object("GtkAdjustment",
                                        template='adjustment',
-                                       properties=dict(value=value,
-                                                       lower=lower,
-                                                       upper=upper,
-                                                       step_increment=step,
-                                                       page_increment=page,
-                                                       page_size=page_size))
+                                       properties=properties)
         prop.childNodes[0].data = adj.getAttribute('id')
 
     def _convert_combobox_items(self, node, prop):